package com.lxw.rmg.menu.controller;

import java.util.Arrays;
import java.util.Map;


import com.lxw.common.utils.PageUtils;
import com.lxw.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.lxw.rmg.menu.entity.NutrientTableEntity;
import com.lxw.rmg.menu.service.NutrientTableService;



/**
 * 营养成分表
 *
 * @author lxw
 * @email 
 * @date 2023-03-25 20:19:52
 */
@RestController
@RequestMapping("menu/nutrienttable")
public class NutrientTableController {
    @Autowired
    private NutrientTableService nutrientTableService;

    /**
     * 列表
     */
    @RequestMapping("/list")
//    @RequiresPermissions("menu:nutrienttable:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = nutrientTableService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
//    @RequiresPermissions("menu:nutrienttable:info")
    public R info(@PathVariable("id") Integer id){
		NutrientTableEntity nutrientTable = nutrientTableService.getById(id);

        return R.ok().put("nutrientTable", nutrientTable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
//    @RequiresPermissions("menu:nutrienttable:save")
    public R save(@RequestBody NutrientTableEntity nutrientTable){
		nutrientTableService.save(nutrientTable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
//    @RequiresPermissions("menu:nutrienttable:update")
    public R update(@RequestBody NutrientTableEntity nutrientTable){
		nutrientTableService.updateById(nutrientTable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
//    @RequiresPermissions("menu:nutrienttable:delete")
    public R delete(@RequestBody Integer[] ids){
		nutrientTableService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
